import type { ProductAttr, ProductAttrDto, ProductAttrInfo, ProductAttrPageDto } from '@/models/productAttr'
import type { CommonResult, CommonPage } from '@/models/request'
import request from '@/utils/request'
export function fetchList(cid: number, params: ProductAttrPageDto) {
  return request<CommonPage<ProductAttr>>({
    url: '/productAttribute/list/' + cid,
    method: 'get',
    params: params,
  })
}

export function deleteProductAttr(data: { ids: string }) {
  return request<CommonResult>({
    url: '/productAttribute/delete',
    method: 'post',
    data: data,
  })
}

export function createProductAttr(data: ProductAttrDto) {
  return request<CommonResult>({
    url: '/productAttribute/create',
    method: 'post',
    data: data,
  })
}

export function updateProductAttr(data: ProductAttrDto) {
  return request<CommonResult>({
    url: '/productAttribute/update/' + data.id,
    method: 'post',
    data: data,
  })
}
export function getProductAttr(id: number) {
  return request<CommonResult<ProductAttr>>({
    url: '/productAttribute/' + id,
    method: 'get',
  })
}

export function getProductAttrInfo(productCategoryId: number) {
  return request<CommonResult<ProductAttrInfo[]>>({
    url: '/productAttribute/attrInfo/' + productCategoryId,
    method: 'get',
  })
}
